package org.oslims.server.dao.hbm;

import java.util.List;

import org.hibernate.Query;
import org.oslims.domain.Parameter;
import org.oslims.server.dao.ParameterDao;

public class HbmParameterDao extends HbmGenericDao<Parameter, Long> implements ParameterDao {

	@SuppressWarnings("unchecked")
	@Override
	public List<Parameter> findAll(int start, int length, String sortBy, Boolean desc) {

		String sortDirection = "asc";

		if (desc)
			sortDirection = "desc";

		Query q = this.getSession().createQuery("select distinct p from Parameter p order by p." + sortBy + " " + sortDirection);

		q.setFirstResult(start);
		q.setMaxResults(length);

		return q.list();

	}

}
